class EntranceController{
    constructor($timeout,$interval,$rootScope,$scope,UserService,AccountService){
        Object.assign(this,{$timeout,$interval,$rootScope,$scope,UserService,AccountService});
        this.$rootScope.isAtLotteryPage = false;
        this.$scope.marqueeString = "dddddddd";
        this.init();
    }

    init(){
        let self = this;
        self.AccountService.getNoticeInfo({ignoreLoadingBar:true}).then(_success).catch(_error);
        function _success(data) {
            // if(data.success==true){
            self.noticeList = data.data.data_list.slice(0,2);
            self.$timeout(function () {
                self.marquee();
            },100);
        }
        function _error(reason) {
            console.log(JSON.stringify(reason));
            // layer.alert(reason&&reason.text?reason.text:"对不起操作失败！",{
            //     title:"错误",
            //     icon: 2,
            //     btn:["知道了"],
            //     btn1:function (index,layerro) {
            //         layer.close(index);
            //     }
            // });
        };
    }
    marquee(){
        let self = this;
        let marqueeWith = $('#marquee2').width();
        let ulEle= $('#marquee2 ul');
        let ulWidth = ulEle.width();
        var position = ulEle.position();
        ulEle.animate({'left': '-'+(ulWidth)+'px'},8000);
        self.interval =  self.$interval(function(){
           ulEle.animate({'left': marqueeWith +'px'},10);
            self.$timeout(function(){
                ulEle.animate({'left': '-'+(ulWidth)+'px'},8000);
            },10);
        },8010);
    }
    toastDetail($event){
       let ulEle =  angular.element($event.target);
       console.log(ulEle);
    }
    stopmarquee($event){
        // angular.element($event.target).toggleClass("selected");
    }
    restartmarquee($event){
        // angular.element($event.target).toggleClass("selected");
    }
}
EntranceController.$inject = ["$timeout","$interval","$rootScope","$scope","UserService","AccountService"];

export default EntranceController;